<template>

<!--BEGIN HEADER-->
<div class="pure-menu pure-menu-open pure-menu-horizontal pure-menu-fixed head-menu">
        <a href="#" class="pure-menu-heading">
            <h3>物联网-金额管理项目</h3>
        </a>
        <ul>
            <li class="pure-menu-selected"><a href="#">主页</a></li>
            <li><a href="#" @click="TakeInfo('pw')" v-show="UserType.UT_Name == '管理员'" >项目管理</a></li>
            <li><a href="#" @click="TakeInfo('IManage')">投资管理</a></li>
            <li><a href="#">标签页</a></li>
            <li><a href="#">标签页</a></li>
        </ul>
        <div class="head-menu-info">
            欢迎您，{{ UserType.UT_Name }} <a href="#"> {{ UserType.UL_Name }} </a>。您选择【首页】【退出】
        </div>
    </div>
    <!--END HEADER-->
    <div class="pure-g content">
        <div class="pure-u-1">
            <div class="main">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div v-show="PWang" >
                            <ShowInvestInfo  ></ShowInvestInfo>
                        </div>
                        
                        <div v-show="IManage && UserType.UT_Name == '用户'">
                            <ShowUserInvestInfo></ShowUserInvestInfo>
                        </div>

                        <div v-show="IManage && UserType.UT_Name == '管理员'">
                            <ShowAllUserInvest></ShowAllUserInvest>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>

</template>

<script setup lang="ts">
import {useUserStore} from '../store/index.ts'
import {ref,onMounted} from 'vue'
import axios from 'axios'

import ShowInvestInfo from '../View/Invest/ShowInvestInfo.vue'
import ShowUserInvestInfo from '../View/Invest/ShowUserInvestInfo.vue'//用户 投资
import ShowAllUserInvest from '../View/Invest/ShowAllUserInvest.vue'//管理员 投资



const userStore = useUserStore()

console.log(userStore.UId);

const UserType = ref({
    UT_Name:'',
    UL_Name:''
})

onMounted(()=>{
    SearUserType();
})

//加载用户信息
const SearUserType = ()=>{
    axios({
        method:'get',
        url:'http://localhost:63517/api/User/SearUserType',
        params:{
            Id:userStore.UId
        }
    })
    .then(res=>{
        console.log(res.data);
        UserType.value = res.data[0] 
    })
    .catch(err=>{
        console.log(err);
    })
}

//
const PWang = ref(false);
const IManage = ref(false);
const TakeInfo = (choose:string)=>{
    switch(choose){
        case 'pw':
            PWang.value = true;
            IManage.value = false;
        break;

        case 'IManage':
            IManage.value = true;
            PWang.value = false;
        break;

        
    }
}
</script>